<?php

namespace app\api\model;

use think\Model;

class Common extends Model
{
    static public $returns;
    public $return;

    public function initialize()
    {
        parent::initialize();

        self::$returns = changeCode(config('code'));

        $this->return = changeCode(config('code'));
    }

    static protected function pass($data)
    {
        $field = is_string($data) ? 'msg' : 'data';

        return json(['code' => 200, $field => $data]);
    }

    static protected function miss($msg, $code = 400)
    {
        return json(['code' => $code, 'msg' => $msg]);
    }
}

